#include "dish_type.h"

DishType::DishType(string dish_type_name){
    this->m_dish_type_name = dish_type_name;
}

void DishType::add_dish(Dish dish){
    //cout << dish.get_name() << dish.get_price() << endl;
    this->m_dishes.push_back(dish);
    if (this->m_dishes.empty()) {
        cout << "没加进去" << endl;
        return;
    }
    // cout <<"----------------1 "<< endl;
    // list<Dish>::iterator it;
    // for(it = this->m_dishes.begin(); it != this->m_dishes.end(); ++it){
    //     cout << "菜名：" << (*it).get_name() << "菜价格：" <<(*it).get_price() << endl;
    // }
    // cout <<"----------------2 "<< endl;
}

void DishType::print_dish_type(){
    cout << "菜系名称：" << this->m_dish_type_name << endl;
}

void DishType::print_dish(){
    // 如果列表为空，直接返回
    // if (this->m_dishes.empty()) {
    //     cout << "没有菜品信息。" << endl;
    //     return;
    // }
    list<Dish>::iterator it;
    for(it = this->m_dishes.begin(); it != this->m_dishes.end(); ++it){
        cout << "菜名：" << (*it).get_name() << "菜价格：" <<(*it).get_price() << endl;
    }
}

list<Dish> DishType::getdishes(){
    return this->m_dishes;
}
//返回链表的开始迭代器
list<Dish>::iterator DishType::begin(){
    return this->m_dishes.begin();
}
//返回链表的结束迭代器
list<Dish>::iterator DishType::end(){
    return this->m_dishes.end();
}

DishType::~DishType(){
}